<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<head>
	<meta charset="utf-8" />
	<meta name="keywords" content="pinpin社保" />
	<meta name="description" content="pinpin社保" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>社保运营后台-代理员工</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
<script language="javascript">
function resetForm() {
	$("#queryEmployeeForm").find("input[type=text],select").val("");
}
function selectAll(btn,items){
  	var selectAll=btn;
  	var nid_var=document.getElementsByName(items);
  	for(var i = 0; i < nid_var.length; i ++ ) {
		nid_var[i].checked = selectAll.checked;
	}
}

function enableSelect(order_no){
  $("#recon_result"+order_no).removeAttr("disabled");
}

function updateReconResult(order_no, recon_result){
	  var data = {
         	"order_no": order_no,
         	"recon_result": recon_result.value
         };
		jQuery.ajax({
			url: "/sba/employee/updaterecon",
			data: data,
			type:'get', 
			async : true, //默认为true 异步   
			error: function(jqXHR, textStatus, errorThrown) {
		 		 //alert(textStatus, errorThrown);
			},
			success:function(result){
			   //jQuery("#update_result").html(result);
			   alert("状态更新成功！");
			   $("#recon_result"+order_no).attr("disabled","disabled");
			}
		});
		
}
function batchRecon(selectName, resultValue) {
	var nid_var = document.getElementsByName(selectName);
	var checkedCount = 0;
	var ids=new Array();
	for(var i = 0; i < nid_var.length; i ++ ) {
		if(nid_var[i].checked) {
		    ids.push(nid_var[i].value);
		}
	}
	checkedCount=ids.length;
	if(0==checkedCount) {
		alert("没有所选项！");
		return;
	} else {
		var updateOk= confirm("确定要更新" + checkedCount + "项吗");
		if(updateOk) {
		 	var data = {
	         	"eids": ids.join(","),
	         	"recon_result": resultValue
	         };
			jQuery.ajax({
				url: "/sba/employee/batchrecon",
				data: data,
				type:'post', 
				async : true, //默认为true 异步   
				error: function(jqXHR, textStatus, errorThrown) {
			 		 //alert(textStatus, errorThrown);
				},
				success:function(result){
				   //jQuery("#update_result").html(result);
				   alert("状态更新成功！");
				   window.location.reload(true);
				}
			});
		}
		alert("更新操作在后台已执行，请耐心等待或稍候刷新页面看结果！");
	}
	
}

function checkDate() {
	if($("#month").val() != '') {
		if(!$.isNumeric($("#month").val())){
			alert("日期只允许数字格式，请勿输入非数字！");
			return false;
		}
	}
}
function toggleDiv(id) {
	$(id).toggle();
}
 </script>
</head>
<body>
	<div id="wrapper">
		<%@ include file="/WEB-INF/jsp/common/menu.jsp" %>
        <div id="page-wrapper">
        	<div class="row">
                <div class="col-lg-12">
                    <!-- 路径导航 -->
                    <ol class="breadcrumb">
				      <li>社保后台</li>
                      <li>员工管理</li>
				      <li class="active">代理员工</li>
				    </ol>
                </div>
            </div>
            <div class="row">
            	<div class="col-lg-12">
            		<div class="panel panel-default">
            			<div class="panel-body">
        			    	<div class="form-inline dt-bootstrap no-footer">
        			    		<!-- 表单查询 -->
        			    		<form action="" method="get" class="form-check" id="queryEmployeeForm">
        			    		<div class="row">
        			    			<div class="col-lg-12">
	        			    			<input type="text" class="form-control" id="month" name="month" placeholder="请输入年月" onClick="WdatePicker({dateFmt:'yyyyMM',minDate:'2015-10-01 00:00:00'})" value="${employeeQueryForm.month}" onblur="return checkDate()">
	       			    				<input type="text" class="form-control" name="order_no" placeholder="请输入订单号" value="${employeeQueryForm.order_no }">
                                        <select class="form-control" name="pcity_code" onchange="javascript:pcityChange(this, 'city_code');" style="color:#ff0000">
                                        	<option value="">${pCitySet.size() }个省市可选</option>
                                            <c:forEach var="pcity" items="${pCitySet }">
                                            <option value="${pcity.id }"> ${pcity.name }</option>
                                            </c:forEach>
                                        </select>
                                        <select class="form-control" name="city_code" id="city_code" style="color:#ff0000">
                                        	<option value="">${existedCityList.size() }个城市可选</option>
                                            <c:forEach var="city" items="${existedCityList }">
                                            <option value="${city.id }" <c:if test="${employeeQueryForm.city_code eq city.id }">selected="selected"</c:if>><c:if test="${0 eq city.isCity }">--</c:if>[${city.id }]${city.name }</option>
                                            </c:forEach>
                                        </select>
                                        <input type="text" class="form-control" name="id_card" placeholder="请输入身份证号码" value="${employeeQueryForm.id_card}">
                                        <select class="form-control" name="pay_for">
                                            <option value="">请选择购买类型</option>
                                            <option value="1" <c:if test="${employeeQueryForm.pay_for eq 1 }">selected="selected"</c:if>>社保</option>
                                            <option value="2" <c:if test="${employeeQueryForm.pay_for eq 2 }">selected="selected"</c:if>>公积金</option>
                                            <option value="3" <c:if test="${employeeQueryForm.pay_for eq 3 }">selected="selected"</c:if>>社保+公积金</option>
                                        </select>
                                        <select class="form-control" name="hukou">
                                            <option value="">请选择户籍类型</option>
                                            <option value="1" <c:if test="${employeeQueryForm.hukou eq 1 }">selected="selected"</c:if>>本市城镇</option>
                                            <option value="2" <c:if test="${employeeQueryForm.hukou eq 2 }">selected="selected"</c:if>>本市农村</option>
                                            <option value="3" <c:if test="${employeeQueryForm.hukou eq 3 }">selected="selected"</c:if>>外地城镇</option>
                                            <option value="4" <c:if test="${employeeQueryForm.hukou eq 4 }">selected="selected"</c:if>>外地农村</option>
                                        </select>
                                        <select class="form-control" name="pay_type">
                                            <option value="">请选择是否新增</option>
                                            <option value="0" <c:if test="${employeeQueryForm.pay_type eq 0 }">selected="selected"</c:if>>新增</option>
                                            <option value="2" <c:if test="${employeeQueryForm.pay_type eq 2 }">selected="selected"</c:if>>非新增</option>
                                        </select>
                                        <input type="hidden" name="pageNo" value="${employeeQueryForm.pageNo }">
                                        <input type="hidden" name="v" value="1">
        			    			    <button type="submit" class="btn btn-primary">查 询</button>
        			    			    <button type="button" class="btn btn-primary" onclick="resetForm()">重置</button>
        			    			</div>
        			    		</div>
        			    		</form>
        			    		<!-- 分页 -->
        			    		<c:set var="page_link" value="?month=${employeeQueryForm.month }&order_no=${employeeQueryForm.order_no }&city_code=${employeeQueryForm.city_code }&user_name=${employeeQueryForm.user_name }&id_card=${employeeQueryForm.id_card }&pay_for=${employeeQueryForm.pay_for }&pay_type=${employeeQueryForm.pay_type }&hukou=${employeeQueryForm.hukou }&funds_amount_start=${employeeQueryForm.funds_amount_start }&funds_amount_end=${employeeQueryForm.funds_amount_end }&shebao_amount_start=${employeeQueryForm.shebao_amount_start }&shebao_amount_end=${employeeQueryForm.shebao_amount_end }&v=1"></c:set>
                            <c:set var="pre_disabled" value=""></c:set>
		    				<c:if test="${pageModel.pageNo le 1}">
		    					<c:set var="pre_disabled" value="disabled"></c:set>
		    				</c:if>
		    				<c:set var="next_disabled" value=""></c:set>
		    				<c:if test="${pageModel.pageNo ge pageModel.pageTotal}">
		    					<c:set var="next_disabled" value="disabled"></c:set>
		    				</c:if>
        			    		<div class="row">
        			    			<div class="col-lg-12">
        			    			<form action="" method="get">
        			    				<div class="ss-pagination">
                                            <span class="ui-text-box">共${pageModel.totalRecord }条 ${pageModel.pageTotal }页</span>
                                            <span class="ui-text-box">每页${pageModel.pageSize }条</span>
                                            <span class="ui-text-box">当前第${pageModel.pageNo }页</span>
        			    					<ul class="pagination">
        			    						<li class="previous ${pre_disabled }" tabindex="0"><a href="${page_link }pageNo=${pageModel.previousPageNo }">上一页</a></li>
        			    						<%@ include file="../page_queue.jsp" %>
        			    						<li class="next ${next_disabled }" tabindex="0"><a href="${page_link }pageNo=${pageModel.nextPageNo }">下一页</a></li>
        			    					</ul>
                                            <span>向第</span>
                                            <input type="text" class="form-control" name="pageNo" size="3">
                                            <span>页</span>
                                            <input type="hidden" class="form-control" name="order_no" value="${employeeQueryForm.order_no }">
                                            <input type="hidden" class="form-control" name="month" value="${employeeQueryForm.month }">
                                            <input type="hidden" class="form-control" name="city_code" value="${employeeQueryForm.city_code }">
                                            <input type="hidden" class="form-control" name="id_card" value="${employeeQueryForm.id_card }">
                                            <input type="hidden" class="form-control" name="pay_for" value="${employeeQueryForm.pay_for }">
                                            <input type="hidden" class="form-control" name="pay_type" value="${employeeQueryForm.pay_type }">
                                            <input type="hidden" class="form-control" name="hukou" value="${employeeQueryForm.hukou }">
                                            <input type="hidden" class="form-control" name="funds_amount_start" value="${employeeQueryForm.funds_amount_start }">
                                            <input type="hidden" class="form-control" name="funds_amount_end" value="${employeeQueryForm.funds_amount_end }">
                                            <input type="hidden" class="form-control" name="shebao_amount_start" value="${employeeQueryForm.shebao_amount_start }">
                                            <input type="hidden" class="form-control" name="shebao_amount_end" value="${employeeQueryForm.shebao_amount_end }">
                                            <button type="submit" class="btn btn-primary">跳转</button>
        			    				</div>
        			    				</form>
        			    			</div>
        			    		</div>
        			    		<hr />
                                <div class="row">
                                    <div class="col-lg-12  toggle_vis">
                                        <button type="button" class="btn btn-primary btn-sm showcol">列段显示/隐藏</button><br/>
                                        <div class="form-group showBox" id="column">
                                        </div>
                                    </div>
                                </div>                               
        			    		<!-- 表格列表 -->
        			    		<div class="row">
        			    			<div class="col-lg-12 width-auto">
        			    				<table id="dataContent" class="table table-striped table-bordered table-hover no-footer dataTable" role="grid">
        			    					<thead>
        			    						<tr>
                                                    <th><label><input type="checkbox" id="selectAll" name="selectAll" onclick="javascript:selectAll(this,'eids')">全选</label></th>
                                                    <th width="50">购买城市</th>
                                                    <th>姓名</th>
                                                    <th>身份证号码</th>
                                                    <th>新增</th>
                                                    <th>手机号</th>
                                                    <th>性别</th>
                                                    <th>民族</th>
                                                    <th>户籍类型</th>
                                                    <th>购买类型</th>
                                                    <th>公积金金额</th>
                                                    <th>社保费(不含残保金)</th>
                                                    <th>残保金</th>
                                                    <th>服务费</th>
                                                    <th>缴费金额</th>
                                                    <th>补退款</th>
                                                    <th>费用所属月份</th>
                                                    <th>订单月份</th>
                                                    <th>补缴增员月份</th>
                                                    <th>生成时间</th>
                                                    <th>核对结果</th>
                                                    <th>订单号</th>
                                                </tr>
        			    					</thead>
        			    					<tbody>
											<c:choose>
        			    						<c:when test="${empty pageModel.recordList }">
        			    							没有找到相关记录啊
        			    						</c:when>
        			    						<c:otherwise>
												<c:forEach items="${pageModel.recordList }" var="employee">
	        			    					<tr role="row">
	        			    							<td><input type="checkbox" name="eids" value="${employee.order_no }"></td>
	                                                    <td>
															<c:forEach var="city" items="${cityList }">
															<c:if test="${employee.city_code eq city.id }">[${city.id }]${city.name }</c:if>
															</c:forEach>
														</td>
	                                                    <td>${employee.user_name }</td>
	                                                    <td>${employee.id_card }
	                                                    </td>
	                                                    <td>
	                                                    <c:if test="${employee.pay_type  eq 0 }">是</c:if>
	                                                    </td>
	                                                    <td>${employee.phone }</td>
	                                                    <td>
	                                                    <c:if test="${employee.gender  eq 1 }">男</c:if>
	                                                    <c:if test="${employee.gender  eq 0 }">女</c:if>
	                                                    </td>
	                                                    <td>${employee.nation}</td>
	                                                    <td>
	                                                    <c:if test="${employee.hukou eq 1 }">本市城镇</c:if>
			                                            <c:if test="${employee.hukou eq 2 }">本市农村</c:if>
			                                            <c:if test="${employee.hukou eq 3 }">外地城镇</c:if>
			                                            <c:if test="${employee.hukou eq 4 }">外地农村</c:if>
														</td>
	                                                    <td>
														<c:if test="${employee.pay_for  eq 1 }">社保
															<c:if test="${employee.new_card == 1 }">(新办卡)</c:if>
															<c:if test="${employee.new_card == 2 }">(补办卡)</c:if>
														</c:if>
	                                                    <c:if test="${employee.pay_for  eq 2 }">公积金</c:if>
														</td>
	                                                    <td>${employee.funds}</td>
	                                                    <td>
	                                                    <c:if test="${employee.shebaos - employee.disabled gt 0}">${employee.shebaos - employee.disabled}</c:if>
	                                                    </td>
	                                                    <td>
	                                                    <c:if test="${employee.shebaos - employee.disabled gt 0}">${employee.disabled}</c:if>
	                                                    </td>
	                                                    <td>${employee.shebao_charge + employee.fund_charge + employee.card_charge}</td>
	                                                    <td>${employee.total_fee}</td>
	                                                    <td>
															<c:choose>
															<c:when test="${employee.refundType eq 1 }">
																-${employee.total_fee}
															</c:when>
															<c:otherwise>
															${employee.repayAmount - employee.refundAmount }
															</c:otherwise>
															</c:choose>
														
														</td>
	                                                    <td><fmt:formatNumber pattern="#" type="number" value="${(employee.for_month - (employee.for_month mod 100))/100 }"/>年${employee.for_month mod 100 }月</td>
	                                                    <td><fmt:formatNumber pattern="#" type="number" value="${(employee.order_month - (employee.order_month mod 100))/100 }"/>年${employee.order_month mod 100 }月</td>
	                                                    <td><fmt:formatNumber pattern="#" type="number" value="${(employee.added_month - (employee.added_month mod 100))/100 }"/>年${employee.added_month mod 100 }月</td>
	                                                    <td>${employee.gen_time }</td>
	                                                    <td>
					                                        <select disabled="disabled" class="form-control" id="recon_result${employee.order_no }" name="recon_result" onchange="javascript:updateReconResult('${employee.order_no }',this)">
					                                            <option value="0" <c:if test="${employee.recon_result  eq 0 }">selected="selected"</c:if>>未知</option>
					                                            <option value="1" <c:if test="${employee.recon_result  eq 1 }">selected="selected"</c:if>>一致</option>
					                                            <option value="2" <c:if test="${employee.recon_result  eq 2 }">selected="selected"</c:if>>不一致</option>
					                                        </select>
	                                                    </td>
	                                                    <td>${employee.order_no }</td>
	        			    						</tr>
        			    					</c:forEach>
        			    						</c:otherwise>
        			    					</c:choose>
        			    					
        			    					</tbody>
        			    				</table>
        			    			</div>
        			    		</div>
        			    		<hr />
        			    		<!-- 分页 -->
                                <br/>
        			    		<div class="row">
        			    			<div class="col-lg-12">
        			    			<form action="" method="get">
        			    				<div class="ss-pagination">
                                            <span class="ui-text-box">共${pageModel.totalRecord }条 ${pageModel.pageTotal }页</span>
                                            <span class="ui-text-box">每页${pageModel.pageSize }条</span>
                                            <span class="ui-text-box">当前第${pageModel.pageNo }页</span>
        			    					<ul class="pagination">
        			    						<li class="previous ${pre_disabled }" tabindex="0"><a href="${page_link }pageNo=${pageModel.previousPageNo }">上一页</a></li>
        			    						<%@ include file="../page_queue.jsp" %>
        			    						<li class="next ${next_disabled }" tabindex="0"><a href="${page_link }pageNo=${pageModel.nextPageNo }">下一页</a></li>
        			    					</ul>
                                            <span>向第</span>
                                            <input type="text" class="form-control" name="pageNo" size="3">
                                            <span>页</span>
                                            <input type="hidden" class="form-control" name="order_no" value="${employeeQueryForm.order_no }">
                                            <input type="hidden" class="form-control" name="month" value="${employeeQueryForm.month }">
                                            <input type="hidden" class="form-control" name="city_code" value="${employeeQueryForm.city_code }">
                                            <input type="hidden" class="form-control" name="id_card" value="${employeeQueryForm.id_card }">
                                            <input type="hidden" class="form-control" name="pay_for" value="${employeeQueryForm.pay_for }">
                                            <input type="hidden" class="form-control" name="pay_type" value="${employeeQueryForm.pay_type }">
                                            <input type="hidden" class="form-control" name="hukou" value="${employeeQueryForm.hukou }">
                                            <input type="hidden" class="form-control" name="funds_amount_start" value="${employeeQueryForm.funds_amount_start }">
                                            <input type="hidden" class="form-control" name="funds_amount_end" value="${employeeQueryForm.funds_amount_end }">
                                            <input type="hidden" class="form-control" name="shebao_amount_start" value="${employeeQueryForm.shebao_amount_start }">
                                            <input type="hidden" class="form-control" name="shebao_amount_end" value="${employeeQueryForm.shebao_amount_end }">
                                            <button type="submit" class="btn btn-primary">跳转</button>
        			    				</div>
        			    				</form>
        			    			</div>
        			    		</div>
        			    	</div>
            			</div>
            		</div>
            	</div>
            </div>
        </div>
	</div>
    <script language="javascript">
       $(function(){hideCols();});
    </script>
</body>
</html>
